#include<iostream>
#include<string>
using namespace std;

string player[10001];
double guess[10001];

int main()
{
    double n = 0;
    cin >> n;
    double total = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> player[i] >> guess[i];
        total += guess[i];
    }
    int avg =(int) total / (2*n);
    double error = 100;
    int winner = 101;
    for(int i = 0; i < n; i++)
    {
        if(abs(guess[i]-avg)<error)
        {
            error = abs(guess[i] - avg);
            winner = i;
        }
    }
    cout << avg << " " << player[winner];
    return 0;
}